<template>
    <div class="tab-switcher" :class="[{ 'rounded': rounded }]">
      <div 
        v-for="(tab, index) in tabs" 
        :key="index" 
        class="tab-item"
        :class="{ 'active': activeTab === index }"
        @click="handleTabClick(index)"
      >
        <div class="tab-content">
          <div v-if="tab.icon" class="tab-icon">
            <i :class="tab.icon"></i>
          </div>
          <div class="tab-label">{{ tab.label }}</div>
        </div>
      </div>
    </div>
  </template>
  
  <script setup>
  import { defineProps, defineEmits } from 'vue';
  
  const props = defineProps({
    tabs: {
      type: Array,
      required: true,
      default: () => []
    },
    activeTab: {
      type: Number,
      default: 0
    },
    // theme: {
    //   type: String,
    //   default: 'light',
    //   validator: value => ['light', 'dark'].includes(value)
    // },
    rounded: {
      type: Boolean,
      default: true
    }
  });
  
  const emit = defineEmits(['tab-change']);
  
  const handleTabClick = (index) => {
    emit('tab-change', index);
  };
  </script>
  
  <style lang="scss" scoped>
  .tab-switcher {
    display: flex;
    background-color: var(--tab-bg);
    padding: 4px;
    border-radius: 12px;
    transition: all 0.3s ease;
    
    &.rounded {
      border-radius: 12px;
    }
    
    &.light {
      --tab-bg: #f0f2f5;
      --tab-text: #5a5e66;
      --tab-active-bg: #ffffff;
      --tab-active-text: #1d2939;
      --tab-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    &.dark {
      --tab-bg: #2d3748;
      --tab-text: #a0aec0;
      --tab-active-bg: #4a5568;
      --tab-active-text: #ffffff;
      --tab-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
  }
  
  .tab-item {
    flex: 1;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 8px 0;
    border-radius: 8px;
    color: var(--tab-text);
    font-weight: 500;
    font-size: 14px;
    
    &:hover:not(.active) {
      background-color: var(--tab-hover-bg);
    }
    
    &.active {
      background-color: var(--tab-active-bg);
      color: var(--tab-active-text);
      box-shadow: var(--tab-shadow);
      font-weight: 600;
    }
  }
  
  .tab-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
  }
  
  .tab-icon {
    font-size: 18px;
    margin-bottom: 2px;
  }
  
  .tab-badge {
    position: absolute;
    top: -2px;
    right: 8px;
    background-color: var(--primary-color);
    color: white;
    font-size: 10px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
  }
  
  // 主题变量
  :root, .light {
    --tab-hover-bg: #e4e7eb;
    --primary-color: #2563eb;
  }
  
  .dark {
    --tab-hover-bg: #3d4657;
    --primary-color: #4299e1;
  }
  </style>